package com.zb.zbtcommon.controller;

import com.zb.zbtcommon.dto.ResponseEntity;
import com.zb.zbtcommon.entity.NewsType;
import com.zb.zbtcommon.service.NewsTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/zbt/common/newstype")
public class NewsTypeController {
    //日志文件
    private Logger logger= LoggerFactory.getLogger(NewsTypeController.class);

    @Autowired
    private NewsTypeService newsTypeService;

    @RequestMapping("/listNewsType")
    public ResponseEntity<List<NewsType>> findNewsType(){
        List<NewsType> list = newsTypeService.findNewsType();
        ResponseEntity<List<NewsType>> entity=new ResponseEntity<>();
        try {
            entity.setCode(HttpStatus.OK.value());
            entity.setTarget(list);
        } catch (Exception e) {
            logger.error("地址：/zbt/common/newstype/listNewsType-----------------请求参数无"+e.getMessage());
            e.printStackTrace();
            entity.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            entity.setMessage("查询  学院类型错误");
        }
        return entity;
    }
    @RequestMapping("/findNewsTypeZixun")
    public ResponseEntity<List<NewsType>> findNewsTypeZixun(){
        List<NewsType> list = newsTypeService.findNewsTypeZixun();

        ResponseEntity<List<NewsType>> entity=new ResponseEntity<>();
        try {
            entity.setCode(HttpStatus.OK.value());
            entity.setTarget(list);
        } catch (Exception e) {
            logger.error("地址：/zbt/common/newstype/findNewsTypeZixun-----------------请求参数无"+e.getMessage());
            e.printStackTrace();
            entity.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            entity.setMessage("查询 智伯资讯 类型错误");
        }
        return entity;
    }
}
